<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="Categorias"></h:outputText>
        </ui:define>
        <ui:define name="body">
            <h:form >
                <div align="left" style="margin-bottom: 15px;">
                    <h:commandButton class="btn btn-primary" action="#{categoriaController.prepareCreate}" value="Nova categoria"/>
                </div>
                <h:panelGroup id="categoriasGroup">
                    <fieldset>
                        <div align="left">
                            <legend>
                                <h:outputText value="#{categoriaController.pagination.pageFirstItem + 1}..#{categoriaController.pagination.pageLastItem + 1}/#{categoriaController.pagination.itemsCount}"/>&nbsp;
                                <h:commandLink action="#{categoriaController.previous}" value="#{bundle.Previous} #{categoriaController.pagination.pageSize}" disabled="#{!categoriaController.pagination.hasPreviousPage}"/>&nbsp;
                                <h:commandLink action="#{categoriaController.next}" value="#{bundle.Next} #{categoriaController.pagination.pageSize}" disabled="#{!categoriaController.pagination.hasNextPage}"/>&nbsp;
                            </legend>
                        </div>
                        <table class="table table-hover">
                            <thead>
                                <tr>
                                    <th align="left"><h:outputText value="Código" style="font-style: oblique;"/></th>
                                    <th align="left"><h:outputText value="Nome" style="font-style: oblique;"/></th>
                                    <th align="left"></th>
                                    <th align="left"></th>
                                    <th align="left"></th>
                                </tr>
                            </thead>
                            <tbody>
                                <ui:repeat value="#{categoriaController.items}" var="item">
                                    <tr>
                                        <td align="left">
                                            <h:outputText value="#{item.id}"/>
                                        </td>
                                        <td align="left">
                                            <h:outputText value="#{item.catNome}"/>
                                        </td>
                                        <td><h:commandLink action="#{categoriaController.prepareView}" value="Ver"/></td>
                                        <td><h:commandLink action="#{categoriaController.prepareEdit}" value="Editar"/></td>
                                        <td><h:commandLink action="#{categoriaController.destroy}" value="Remover"/></td>
                                    </tr>
                                </ui:repeat>
                            </tbody>
                        </table>
                        <h:outputText escape="false" value="Sem dados" rendered="#{categoriaController.items.rowCount == 0}"/>
                    </fieldset>
                </h:panelGroup>
            </h:form>
        </ui:define>
    </ui:composition>

</html>
